﻿using System;

namespace NetFrameworkExtensions.Enterprise.Bus
{
  public class EntityChangedEventArgs :
    EventArgs,
    IEntityChangedEventArgs
  {
    public EntityChangedEventArgs(object entity, EntityChangeOperation operation)
    {
      if (entity == null)
        throw new ArgumentNullException("entity");
      Entity = entity;
      Operation = operation;
    }

    public object Entity { get; private set; }

    public EntityChangeOperation Operation { get; private set; }
  }

  public class EntityChangedEventArgs<TEntity> :
    EventArgs,
    IEntityChangedEventArgs
    where TEntity : class
  {
    public EntityChangedEventArgs(TEntity entity, EntityChangeOperation operation)
    {
      if (entity == null)
        throw new ArgumentNullException("entity");
      Entity = entity;
      Operation = operation;
    }

    public TEntity Entity { get; private set; }

    public EntityChangeOperation Operation { get; private set; }

    object IEntityChangedEventArgs.Entity
    {
      get { return this.Entity; }
    }
  }
}
